package sk.uniba.fmph.asdf.tempt;

import sk.uniba.fmph.asdf.test.RelativePoint;

/**
 * Trieda rozirujuca pole sablony o maximalny bodovy zisk.
 *
 * @author Matej
 * @author tim
 * @serial
 */
public class PrimaryTestFieldDef extends TestFieldDef {

	private static final long serialVersionUID = -2373299295522145630L;
	/**
     * maximalny bodovy zisk
     * @serialField
     */
    private int maxPoints;

    @Override
    public void validateState() {
        super.validateState();
        validateMaxPoints(maxPoints);
    }

    /**
     * Validacia hodnoty maximalneho poctu bodov
     * @param maxPoints maximalny pocet bodov
     */
    private void validateMaxPoints(final int maxPoints) {
        if (maxPoints < 0) {
            throw new IllegalArgumentException(String.valueOf(maxPoints));
        }
    }


    public PrimaryTestFieldDef(int id, RelativePoint topLeft, RelativePoint bottomRight, int maxPoints) {
        super(id, topLeft, bottomRight);
        this.maxPoints = maxPoints;
    }

    /**
     * Vrati maximalny pocet bodov.
     * @return maximalny pocet bodov
     */
    public int getMaxPoints() {
        return maxPoints;
    }

    /**
     * Priradi novu hodnotu maximalnemu poctu bodov
     * @param maxPoints maximalny pocet bodov
     */
    public void setMaxPoints(int maxPoints) {
        validateMaxPoints(maxPoints);
        this.maxPoints = maxPoints;
    }

    @Override
    public boolean equals(Object obj) {
    	PrimaryTestFieldDef other = (PrimaryTestFieldDef) obj;
    	return maxPoints == other.maxPoints && super.equals(obj);
    }

    @Override
    public int hashCode() {
        int hash = 5;
        hash = 71 * hash + this.maxPoints;
        return hash;
    }
}
